package org.rayson.server;

import java.util.Properties;

import org.rayson.server.service.ServiceManager;

public class Container {

	private final ConnectionManager connectionManager;

	private SessionManager sessionManager;

	private final WorkerManager workerManager;

	private final RequestManager requestManager;

	private final ServerConfig config;

	private final ServiceManager serviceManager;

	private final Server server;

	Container(final ServerConfig config, final Server server) {
		this.config = config;
		this.server = server;
		this.connectionManager = new ConnectionManager(this);
		this.requestManager = new RequestManager(this);
		this.serviceManager = new ServiceManager(this);
		this.workerManager = new WorkerManager(this);
	}

	public ConnectionManager getConnectionManager() {
		return connectionManager;
	}

	public String getName() {
		return this.server.getName();
	}

	public RequestManager getRequestManager() {
		return requestManager;
	}

	/**
	 * @return the serviceManager
	 */
	public ServiceManager getServiceManager() {
		return serviceManager;
	}

	public SessionManager getSessionManager() {
		return sessionManager;
	}

	public WorkerManager getWorkerManager() {
		return workerManager;
	}

	void start(final Properties properties) throws Exception {
		this.connectionManager.start(null);
		this.workerManager.start(null);
	}

	void stop() {

	}
}